#pragma once

struct MaterialVaoSet
{
	MaterialVaoSet(const Material* material, GLVertexArray* vao) :
		m_material(material), m_vao(vao)
	{}

	const Material* m_material;
	GLVertexArray* m_vao;
};

class MeshInstance;

//http://www.donkerdump.nl/node/207
class Mesh: public IResource
{
public:
	Mesh(const std::string& filename);
	~Mesh();

	/*--------------------------------------------------------------------------*/
	void Reload();

	/*--------------------------------------------------------------------------*/

	const std::vector<MaterialVaoSet>& GetSets() const;
	uint GetSetsCount() const;

	MeshInstance* CreateInstance() const;
	GLVertexArray* GetBoundingBox() const;

	const std::string& GetPath() const;
	void SetPath(const std::string& path);

private:
	void UpdateScalingAndBoundingBox(Lib3dsFile* model);

	std::vector<MaterialVaoSet> m_sets;
	uint m_setsCount;

	glm::vec3 m_maxPositive;
	glm::vec3 m_maxNegative;
	float m_scaling;

	std::string m_path;

	GLVertexArray* m_boundingBox;
};